<template>
	<view class="container" >
		<view class="status_bar">
			<view style="margin-left: 3%;" @tap="goBack()"><u-icon name="arrow-leftward" size='24' /></view>
			<view style="margin-left: -50upx; font-weight: bold;" v-if="type=5"> 修改个性签名 </view>

			<view></view>
			</u-icon>
		</view>
		<!-- <view style="display: flex;">
			<view style="padding: 20upx 0;"><span
					class="icon-title">|</span>{{type=="remark"?"修改备注后，仅自己可见":"修改电话后，仅自己可见"}}</view>
		</view> -->

		<view class="shop-box" v-if="type=='remark'">
			<!-- <u--input v-model="value1" placeholder="请输入内容" height=200 border="none" clearable></u--input> -->
			<u--textarea v-model="value1" placeholder="请输入内容" height=200 border="none" clearable></u--textarea>
		</view>
		<view class="shop-box" v-else>
			<u--textarea v-model="whats_up" placeholder="请输入内容" height=200 border="none" clearable></u--textarea>
		</view>
		<view @click="getcommit" class="btn-box">确定</u-button></view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				startX: 0, // 触摸开始的X坐标
				endX: 0, // 触摸结束的X坐标
				threshold: 50, // 设置滑动多少距离后触发返回
				value1: '',
				value2: '',
				type: '',
				whats_up: ''
			}
		},
		onLoad(props) {
			console.log(props)
			this.type = props.type
			// this.getDetail()
		},
		methods: {
			// 获取信息
			getcommit() {
				// 个性签名
				if (this.type == 5) {
					const newDataObj = {
						"user_desc": this.whats_up, // "1"表示用好友的 mai 
						"uid": uni.getStorageSync('user_uid')
					};
					const newDataJsonStr = JSON.stringify(newDataObj)
					var requestData = {
						"processorId": '1008',
						"jobDispatchId": '1',
						"actionId": '22',
						// "token":uni.getStorageSync('token'), 
						// "token": "123123123123",
						"newData": newDataJsonStr
					};
				}

				const requestDataJsonStr = JSON.stringify(requestData);
				uni.request({
					url: 'http://chat.zwsmcn.com:8090/rest_post',
					header: {
						'content-type': 'application/json'
					},
					data: requestDataJsonStr,
					method: 'POST',
					success: res => {
						console.log(JSON.parse(res.data.returnValue))
						// uni.hideLoading()
						this.itemArr = JSON.parse(res.data.returnValue)
						//  const updateInfoStr = JSON.stringify(res.data.returnValue);
						//   console.log(updateInfoStr);
						//  const updateInfoObj = JSON.parse(updateInfoStr);
						//  console.log(updateInfoObj);
						// console.log(JSON.parse(res.data.returnValue).new_uid);


						console.log(this.itemArr)
					},
					fail: res => {
						console.log(res);
					}
				});
			},
			goBack() {
				uni.navigateBack({
					delta: 1
				});
			},
			
			
			logout() {
				
				// uni.clearStorageSync()
				uni.MBSocketProvider.closeLocalSocket();
				uni.setStorageSync('loginInfo', {});
				uni.setStorageSync('token', '')
				uni.setStorageSync('user_uid', '')
				uni.setStorageSync('userId', '')
				uni.setStorageSync('user_level', '')
				uni.setStorageSync('nickname', '')
				uni.setStorageSync('user_avatar_file_name', '')
				uni.setStorageSync('loginInfoArr', []);
				this.toPage('/pages/login')
			},
			showEdit() {
				this.groupName = this.group.name
				this.$refs.edit.open()
			},
			cancelEdit() {
				this.$refs.edit.close()
			},
			editAction() {
				if (this.$validate.isNull(this.groupName)) return
				this.$util.loading('保存中')
				uni.request({
					method: 'POST',
					url: this.$api.updateGroupName,
					data: {
						groupId: this.groupId,
						userId: this.userId,
						name: this.groupName
					},
					header: this.$util.getHeader(),
					success: res => {
						uni.hideLoading()
						this.$util.toast(res.data.msg)
						if (!res.data.code) {
							this.$refs.edit.close()
							this.group.name = this.groupName
							uni.setStorageSync('groupName', this.groupName)
						}
					},
					fail: res => {
						uni.hideLoading()
						this.$util.toast('保存失败')
					}
				})
			},
			// 上传头像
			uploadFace() {
				uni.chooseImage({
					count: 1,
					success: chooseRes => {
						const tempFilePaths = chooseRes.tempFilePaths

						this.$util.loading('上传中')
						tempFilePaths.forEach(temp => {
							uni.uploadFile({
								url: this.$api.uploadUserFace,
								filePath: temp,
								formData: {
									groupId: this.groupId,
									userId: this.userId
								},
								name: 'file',
								header: this.$util.getHeader(),
								success: uploadRes => {
									uni.hideLoading()
									if (uploadRes.data.code) return
									let data = JSON.parse(uploadRes.data)
									this.user.face = this.$api.staticPath + data.data
									uni.setStorageSync('userFace', this.user.face)
								}
							})
						})
					}
				})
			},
			// 获取信息
			getDetail() {
				this.$util.loading()
				uni.request({
					url: this.$api.getUserInfo,
					data: {
						userId: this.userId
					},
					header: this.$util.getHeader(),
					success: res => {
						uni.hideLoading()
						this.user = res.data.data
						this.user.face = this.user.face ? this.$api.staticPath + this.user.face : ''
					},
					fail: err => {
						uni.hideLoading()
						this.$util.toast('获取失败')
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;
		height: 100%;
	}

	.status_bar {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 50upx;
	}

	.status_bar,
	.head {
		background-color: #fff;
		height: 160upx;

		.face {
			width: 160upx;
			height: 160upx;
			border-radius: 10upx;
		}

		.info-name {
			font-size: 40upx;
			font-weight: bold;
		}

		.info-num {
			// width: 56upx;
			padding: 2upx 30upx;
			background: #f0f4f7;
			border-radius: 30upx;
			margin-top: 21upx;
		}

		.copybtns {
			color: #4457a4;
			margin-top: 21upx;
		}
	}


	.shop-box {
		width: 92%;
		height: 36%;
		margin-left: 4%;
		background-color: #f8f9fb;
		margin-top: 20upx;
		border-radius: 20upx;
		padding: 10upx 30upx;
		color: #2e2e2e;
		font-weight: 300;

		image {
			width: 70upx;
			height: 70upx;
			padding: 10upx 28upx 0upx 10upx;

		}

		::v-deep.u-textarea[data-v-81cd9d32],
		.uni-textarea-textarea {
			background-color: #f8f9fb;
		}

		::v-deep.u-input__content__clear {
			background-color: #1a76f1;
		}
	}

	.btn-box {
		width: 92%;
		margin-left: 4%;
		position: absolute;
		bottom: 80upx;
		background: #1a76f1;
		color: #fff;
		text-align: center;
		height: 80upx;
		line-height: 80upx;
		border-radius: 20upx;
	}

	.icon-title {
		color: #d54827;
		font-weight: bold;
		margin-right: 20upx;
		margin-left: 36upx;
	}
</style>